package CtrLayer;

import java.util.ArrayList;

import DBLayer.*;
import ModelLayer.*;

public class CtrLandlord {
	
	private IFDBLandlord dbLan;
	
	public CtrLandlord(){
		dbLan = DBLandlord.getInstance();
	}
	
	public ArrayList<Landlord> getAll(){
		ArrayList<Landlord> landlords = new ArrayList<Landlord>();
		landlords = dbLan.getAll();
		return landlords;
	}
	
	public ArrayList<Landlord> getAllLandlordsByName(String name){
		ArrayList<Landlord> landlords = new ArrayList<Landlord>();
		landlords = dbLan.getAllLandlordsByName(name);
		return landlords;
	}
	
	public int update(Landlord land){
		return dbLan.update(land);
	}
	
	public ArrayList<Landlord> getAll_where(String wClause){
		return dbLan.getAll_where(wClause);
	}
	
	public ArrayList<Landlord> searchRandom(String searchF) {
		return dbLan.searchRandom(searchF);
	}
	
	public Landlord getLandlordByName(String fname,String lname){
		return dbLan.getLandlordByName(fname,lname);
	}
	
	public Landlord getLandlordByName(String name){
		return dbLan.getLandlordByName(name);
	}
	
	
	public Landlord getLandlordById(int landlordID, boolean takeBankAccount){
		return dbLan.getLandlordById(landlordID,takeBankAccount);
	}
	
	
	public int delete(int landlordID){
		return dbLan.delete(landlordID);
	}
	
	public int insert(int pid, String fname, String lname, String address, String city, String postalCode, String country, String phone, String email, BankAccount bankAccount){
		
		Landlord lan = new Landlord(-1, fname, lname, address, city, postalCode, country, phone, email, bankAccount);
		int rc = -1;
		try{
			rc = dbLan.insert(lan);
		}catch(Exception e){
			e.printStackTrace();
		}
		return rc;
	}
	
	public int update(int pid, String fname, String lname, String address, String city, String postalCode, String country, String phone, String email, BankAccount bankAccount){
		Landlord lan = new Landlord(pid, fname, lname, address, city, postalCode, country, phone, email, bankAccount);
		return dbLan.update(lan);
		
	}

	public int insert(Landlord land) {
		return dbLan.insert(land);
	}
}



